﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Configuration;
using Microsoft.Practices.EnterpriseLibrary.Common.Configuration;

namespace Janus.Cores.Configuration
{
    /// <summary>
    /// 
    /// </summary>
    public static class EBSConfiguration
    {

        static ConfigManager __inner = null;

        /// <summary>
        /// 初始化配置
        /// </summary>
        /// <param name="config"><see cref="ConfigManager"/></param>
        public static void Setup(ConfigManager config)
        {
            __inner = config;
        }

        /// <summary>
        /// 初始化配置
        /// </summary>
        /// <param name="file">配置文件</param>
        public static void Setup(string file)
        {
            __inner = ConfigManager.Create(file, false);
        }

        const string SECTION_NAME = "ebs";
        /// <summary>
        /// 
        /// </summary>
        public static EBSConfigSection Current
        {
            get
            {
                if (__inner == null)
                    return ConfigManager.GetSection<EBSConfigSection>(SECTION_NAME);
                else
                    return (EBSConfigSection)__inner.GetSection(SECTION_NAME);
            }
        }
    }
}
